package com.itheima.collectionDemo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollectionDemo4 {
    public static void main(String[] args) {
        Collection<String> list = new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("b");
        list.add("c");
        list.add("d");

//        method1(list);

        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String next = iterator.next();
            if ("b".equals(next)) {
                iterator.remove();
            }
        }
        System.out.println(list);
    }

    private static void method1(Collection<String> list) {
        list.removeIf((String s) -> s == "b");
        System.out.println(list);
    }
}
